home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / hardware / parallel_port / plpstat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  921 b   |  44 lines

  1. /*
  2.  *   plpstat.c:
  3.  *
  4.  *    Displays the status of the Personal Iris (4D/[20,25]) parallel port.
  5.  *
  6.  *  References:  PLP(7), IOCTL(2), OPEN(2), PERROR(3C) 
  7.  *
  8.  *                                     Grant Dorman - 1990
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include <fcntl.h>
  13. #include <sys/plp.h>
  14.  
  15. main ()
  16.     int f1, iostat;
  17.  
  18.     if ((f1 = open("/dev/plp", O_WRONLY)) == -1) { 
  19.     perror("open"); 
  20.     exit(1); 
  21.     }
  22.     if (ioctl(f1, PLPIOCRESET, 0) == -1) { 
  23.         perror("reset"); 
  24.     exit(1); 
  25.     }
  26.     for (;;) { 
  27.     if ((iostat = ioctl(f1, PLPIOCSTATUS, 0)) == -1) { 
  28.         perror("status"); 
  29.         exit(1); 
  30.     }
  31.         if (iostat & PLPONLINE) 
  32.         fprintf(stderr, "Online, ");
  33.         if (iostat & PLPEOP) 
  34.         fprintf(stderr, "Paper out, ");
  35.         if (iostat & PLPEOI) 
  36.         fprintf(stderr, "Ink out, ");
  37.         if (iostat & PLPFAULT) 
  38.         fprintf(stderr, "Fault. ");
  39.         fprintf(stderr, "\n");
  40.         sleep(2);
  41.     }
  42. }
  43.